package org.nado.bbs;

import java.util.HashMap;
import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface BBSDAO {
	
	@Insert("INSERT INTO TBL_BBS (bbs_no, bbs_title, bbs_content, bbs_writer, bbs_gno) VALUES	(SEQ_bbs_NO.NEXTVAL, #{bbs_title}, #{bbs_content}, #{bbs_writer},	SEQ_bbs_NO.currval)")
	public abstract void registNew(BBSBoardVO vo) throws Exception;
	
	@Select("SELECT SEQ_BBS_NO.CURRVAL FROM dual")
	public abstract int getBBSNo() throws Exception;
	
	@Update("UPDATE TBL_bbs SET bbs_gord = bbs_gord + 1 WHERE bbs_gno = #{bbs_gno} and bbs_gord >= #{bbs_gord}+1")
	public abstract void registGordUpdate(BBSBoardVO vo) throws Exception;
	
	@Insert("INSERT INTO TBL_bbs (bbs_no, bbs_title, bbs_content, BBS_WRITER, bbs_gno, bbs_gord, bbs_pno, bbs_depth) VALUES (SEQ_bbs_NO.NEXTVAL, #{bbs_title}, #{bbs_content}, #{bbs_writer}, #{bbs_gno}, #{bbs_gord}+1, #{bbs_no}, #{bbs_depth}+1)")
	public abstract void registOld(BBSBoardVO vo) throws Exception;
	
	@Update("UPDATE TBL_bbs SET bbs_readcnt = bbs_readcnt+1 WHERE bbs_no =#{bbs_no}")
	public abstract void readCntUpdate(int bbs_no) throws Exception;
	
	@Select("	SELECT BBS_NO, BBS_TITLE, BBS_CONTENT, BBS_WRITER, BBS_REGDATE, BBS_READCNT, BBS_GNO, BBS_GORD, BBS_PNO, BBS_DEPTH from TBL_bbs WHERE bbs_no = #{bbs_no}")
	public abstract BBSBoardVO get(int bbs_no) throws Exception;
	
	@Update("UPDATE TBL_bbs SET bbs_title = #{bbs_title}, bbs_content = #{bbs_content}, bbs_regdate = SYSDATE WHERE bbs_no = #{bbs_no}")
	public abstract void modify(BBSBoardVO vo) throws Exception;
	
	public abstract List<String> getContentCnt(int bbs_no) throws Exception;
	
	public abstract void removeAllReply(int bbs_no) throws Exception;
	
	public abstract void removeRe(int bbs_no) throws Exception;
	
	public abstract void removeOri(int bbs_no) throws Exception;
	
	public abstract List<BBSBoardVO> list(int page_no) throws Exception;
	
	public abstract List<BBSBoardVO> search(HashMap<String, Object> valueMap);

	public abstract void replyRegist(ReplyVO vo) throws Exception;
	
	public abstract void replyUpdateRecnt(ReplyVO vo) throws Exception;
	
	public abstract void replyDelete(ReplyVO vo) throws Exception;
	
	public abstract void replyDisconutRecnt(ReplyVO vo) throws Exception;
	
	public abstract List<ReplyVO> getReplyList(int bbs_rep_no) throws Exception;
	
	public abstract List<BBSBoardVO> dynamicList(SearchVO vo) throws Exception;


}